Sharp Stuff
Switchblades Icepicks and german knives
PHP Gallery
PHP Gallery is a free php image script.
Goth and Gore Gifts
Shop right now or else!
Viking gear
Gear Gifts and Apparel

here are some of the best and useful php scripts and snippets to help in your projects. Php displayed below. Use the search for specific script lookups. Click the category links to view scripts in Javascript and cgi. To add your own script click the link and add your useful script example.

delete file line search delimited csv field value
delete file line csv  field value
<?php
      
function delete_line($file,$field_num,$field_val,$delimiter=';'){
      if(isset(
$file,$field_num,$field_val)){
      
$f fopen($file '.lock''w');
      
flock($fLOCK_SH);
      
$contents file($file);
      
flock($fLOCK_UN);
      
fclose($f);
      
$rows count($contents);
      for ( 
$i 0$i $rows$i++ ){
      
$field explode($delimitertrim($contents[$i]));
      if(
$field_val== $field[$field_num]) { 
      unset(
$contents[$i]);
      }}
       
$filerep implode(""$contents);
       
$filerep preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/""\n"$filerep);
        if(
file_put_contents($file,$filerep,LOCK_EX)){
            return 
true;
        }}}
        
      
$file='cart-data.txt';
//    file - column index number - column value
   
delete_line($file'4''string to match');
?>


Add your comment.













No comments yet

Search ScriptsnTips


Php JavaScripts CGI/Perl